//
//  MineView.m
//  吃货·上海
//
//  Created by 濮亚军 on 15/11/25.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "MineView.h"
@interface MineView()

//图标
@property(nonatomic, strong)UIImageView *iconImageView;

@property(nonatomic, strong)UILabel *titleLabel;

@end

@implementation MineView

-(instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image title:(NSString *)title
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        //self.bgView.backgroundColor = [UIColor redColor];
        [self addSubview:_bgView];
        
        CGFloat width = 3 * frame.size.width / 5;
        CGFloat x = (frame.size.width - width) / 2;
        CGFloat y = (frame.size.height - width) / 2;
        NSLog(@"%f",y);
        self.iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake( x, 5, width, width)];
        self.iconImageView.userInteractionEnabled = YES;
        self.iconImageView.layer.masksToBounds = YES;
        [self.iconImageView.layer setCornerRadius:width / 2];
        //self.iconImageView.backgroundColor = [UIColor redColor];
        self.iconImageView.image = image;
        [self.bgView addSubview:_iconImageView];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(x, 10 + width, width, frame.size.height - 5 - width - 10)];
        //self.titleLabel.backgroundColor = [UIColor redColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.titleLabel.text = title;
        [self.bgView addSubview:_titleLabel];
    }
    return self;
}

@end
